using System;
using System.Data;
using System.Data.SqlTypes;
using System.Data.SqlClient;
using System.Collections.Generic;
using System.Collections;
using BE;

namespace DAL//ModulDuoc.BusinessLayer.DataLayer

{

	/// <summary>
	/// Data access layer class for ZD_PHIEUNHAPKHOCT
	/// </summary>
	public class ZD_PHIEUNHAPKHOCTSql : DataLayerBase 
	{

        #region Constructor

		/// <summary>
		/// Class constructor
		/// </summary>
		public ZD_PHIEUNHAPKHOCTSql()
		{
			// Nothing for now.
		}

        #endregion

        #region Public Methods

        /// <summary>
        /// insert new row in the table
        /// </summary>
		/// <param name="businessObject">business object</param>
		/// <returns>true of successfully insert</returns>
		public bool Insert(ZD_PHIEUNHAPKHOCT businessObject)
		{
			SqlCommand	sqlCommand = new SqlCommand();
			sqlCommand.CommandText = "dbo.[zD_PHIEUNHAPKHOCT_Insert]";
			sqlCommand.CommandType = CommandType.StoredProcedure;

			// Use connection object of base class
			sqlCommand.Connection = MainConnection;

			try
			{
                
				sqlCommand.Parameters.Add(new SqlParameter("@id", SqlDbType.BigInt, 8, ParameterDirection.Output, false, 0, 0, "", DataRowVersion.Proposed, businessObject.Id));
				sqlCommand.Parameters.Add(new SqlParameter("@sophieu", SqlDbType.NVarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.Sophieu));
				sqlCommand.Parameters.Add(new SqlParameter("@mavt", SqlDbType.NVarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.Mavt));
				sqlCommand.Parameters.Add(new SqlParameter("@mavach", SqlDbType.BigInt, 8, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.Mavach));
				sqlCommand.Parameters.Add(new SqlParameter("@solo", SqlDbType.NVarChar, 30, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.Solo));
				sqlCommand.Parameters.Add(new SqlParameter("@soluong", SqlDbType.Float, 8, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.Soluong));
				sqlCommand.Parameters.Add(new SqlParameter("@dongianhap", SqlDbType.Float, 8, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.Dongianhap));
				sqlCommand.Parameters.Add(new SqlParameter("@thanhtien", SqlDbType.Float, 8, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.Thanhtien));
				sqlCommand.Parameters.Add(new SqlParameter("@ngaysx", SqlDbType.DateTime, 8, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.Ngaysx));
				sqlCommand.Parameters.Add(new SqlParameter("@hansd", SqlDbType.DateTime, 8, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.Hansd));
				sqlCommand.Parameters.Add(new SqlParameter("@sodutru", SqlDbType.BigInt, 8, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.Sodutru));
				sqlCommand.Parameters.Add(new SqlParameter("@nhacc", SqlDbType.NVarChar, 10, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.Nhacc));
				sqlCommand.Parameters.Add(new SqlParameter("@hopdong", SqlDbType.BigInt, 8, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.Hopdong));
				sqlCommand.Parameters.Add(new SqlParameter("@baogia", SqlDbType.NVarChar, 30, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.Baogia));
				sqlCommand.Parameters.Add(new SqlParameter("@stt", SqlDbType.SmallInt, 2, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.Stt));
				sqlCommand.Parameters.Add(new SqlParameter("@ghichu", SqlDbType.NVarChar, 100, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.Ghichu));
				sqlCommand.Parameters.Add(new SqlParameter("@vat", SqlDbType.Float, 8, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.Vat));
				sqlCommand.Parameters.Add(new SqlParameter("@giaban", SqlDbType.Float, 8, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.Giaban));

								
				MainConnection.Open();
				
				sqlCommand.ExecuteNonQuery();
                businessObject.Id = (long)sqlCommand.Parameters["@id"].Value;

				return true;
			}
			catch(Exception ex)
			{				
				throw new Exception("ZD_PHIEUNHAPKHOCT::Insert::Error occured.", ex);
			}
			finally
			{			
				MainConnection.Close();
				sqlCommand.Dispose();
			}
		}

         /// <summary>
        /// update row in the table
        /// </summary>
        /// <param name="businessObject">business object</param>
        /// <returns>true for successfully updated</returns>
        public bool Update(ZD_PHIEUNHAPKHOCT businessObject)
        {
            SqlCommand sqlCommand = new SqlCommand();
            sqlCommand.CommandText = "dbo.[zD_PHIEUNHAPKHOCT_Update]";
            sqlCommand.CommandType = CommandType.StoredProcedure;

            // Use connection object of base class
            sqlCommand.Connection = MainConnection;

            try
            {
                
				sqlCommand.Parameters.Add(new SqlParameter("@id", SqlDbType.BigInt, 8, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.Id));
				sqlCommand.Parameters.Add(new SqlParameter("@sophieu", SqlDbType.NVarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.Sophieu));
				sqlCommand.Parameters.Add(new SqlParameter("@mavt", SqlDbType.NVarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.Mavt));
				sqlCommand.Parameters.Add(new SqlParameter("@mavach", SqlDbType.BigInt, 8, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.Mavach));
				sqlCommand.Parameters.Add(new SqlParameter("@solo", SqlDbType.NVarChar, 30, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.Solo));
				sqlCommand.Parameters.Add(new SqlParameter("@soluong", SqlDbType.Float, 8, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.Soluong));
				sqlCommand.Parameters.Add(new SqlParameter("@dongianhap", SqlDbType.Float, 8, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.Dongianhap));
				sqlCommand.Parameters.Add(new SqlParameter("@thanhtien", SqlDbType.Float, 8, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.Thanhtien));
				sqlCommand.Parameters.Add(new SqlParameter("@ngaysx", SqlDbType.DateTime, 8, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.Ngaysx));
				sqlCommand.Parameters.Add(new SqlParameter("@hansd", SqlDbType.DateTime, 8, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.Hansd));
				sqlCommand.Parameters.Add(new SqlParameter("@sodutru", SqlDbType.BigInt, 8, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.Sodutru));
				sqlCommand.Parameters.Add(new SqlParameter("@nhacc", SqlDbType.NVarChar, 10, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.Nhacc));
				sqlCommand.Parameters.Add(new SqlParameter("@hopdong", SqlDbType.BigInt, 8, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.Hopdong));
				sqlCommand.Parameters.Add(new SqlParameter("@baogia", SqlDbType.NVarChar, 30, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.Baogia));
				sqlCommand.Parameters.Add(new SqlParameter("@stt", SqlDbType.SmallInt, 2, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.Stt));
				sqlCommand.Parameters.Add(new SqlParameter("@ghichu", SqlDbType.NVarChar, 100, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.Ghichu));
				sqlCommand.Parameters.Add(new SqlParameter("@vat", SqlDbType.Float, 8, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.Vat));
				sqlCommand.Parameters.Add(new SqlParameter("@giaban", SqlDbType.Float, 8, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.Giaban));

                
                MainConnection.Open();

                sqlCommand.ExecuteNonQuery();
                return true;
            }
            catch (Exception ex)
            {
                throw new Exception("ZD_PHIEUNHAPKHOCT::Update::Error occured.", ex);
            }
            finally
            {
                MainConnection.Close();
                sqlCommand.Dispose();
            }
        }

        /// <summary>
        /// Delete by primary key
        /// </summary>
        /// <param name="keys">primary keys</param>
        /// <returns>true for successfully deleted</returns>
        public bool Delete(ZD_PHIEUNHAPKHOCTKeys keys)
        {
            SqlCommand sqlCommand = new SqlCommand();
            sqlCommand.CommandText = "dbo.[zD_PHIEUNHAPKHOCT_DeleteByPrimaryKey]";
            sqlCommand.CommandType = CommandType.StoredProcedure;

            // Use connection object of base class
            sqlCommand.Connection = MainConnection;

            try
            {

				sqlCommand.Parameters.Add(new SqlParameter("@id", SqlDbType.BigInt, 8, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, keys.Id));


                MainConnection.Open();

                sqlCommand.ExecuteNonQuery();

                return true;
            }
            catch (Exception ex)
            {
                throw new Exception("ZD_PHIEUNHAPKHOCT::DeleteByKey::Error occured.", ex);
            }
            finally
            {                
                MainConnection.Close();
                sqlCommand.Dispose();
            }

        }

        /// <summary>
        /// Delete records by field
        /// </summary>
        /// <param name="fieldName">name of field</param>
        /// <param name="value">value of field</param>
        /// <returns>true for successfully deleted</returns>
        public bool DeleteByField(string fieldName, object value)
        {
            SqlCommand sqlCommand = new SqlCommand();
            sqlCommand.CommandText = "dbo.[zD_PHIEUNHAPKHOCT_DeleteByField]";
            sqlCommand.CommandType = CommandType.StoredProcedure;

            // Use connection object of base class
            sqlCommand.Connection = MainConnection;

            try
            {

                sqlCommand.Parameters.Add(new SqlParameter("@FieldName", fieldName));
                sqlCommand.Parameters.Add(new SqlParameter("@Value", value));
                
                MainConnection.Open();

                sqlCommand.ExecuteNonQuery();

                return true;

            }
            catch (Exception ex)
            {                
                throw new Exception("ZD_PHIEUNHAPKHOCT::DeleteByField::Error occured.", ex);
            }
            finally
            {             
                MainConnection.Close();
                sqlCommand.Dispose();
            }

        }
        /// <summary>
        /// Select by primary key
        /// </summary>
        /// <param name="keys">primary keys</param>
        /// <returns>ZD_PHIEUNHAPKHOCT business object</returns>
        public ZD_PHIEUNHAPKHOCT SelectByPrimaryKey(ZD_PHIEUNHAPKHOCTKeys keys)
        {
            SqlCommand sqlCommand = new SqlCommand();
            sqlCommand.CommandText = "dbo.[zD_PHIEUNHAPKHOCT_SelectByPrimaryKey]";
            sqlCommand.CommandType = CommandType.StoredProcedure;

            // Use connection object of base class
            sqlCommand.Connection = MainConnection;

            try
            {

				sqlCommand.Parameters.Add(new SqlParameter("@id", SqlDbType.BigInt, 8, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, keys.Id));

                
                MainConnection.Open();

                IDataReader dataReader = sqlCommand.ExecuteReader();

                if (dataReader.Read())
                {
                    ZD_PHIEUNHAPKHOCT businessObject = new ZD_PHIEUNHAPKHOCT();

                    PopulateBusinessObjectFromReader(businessObject, dataReader);

                    return businessObject;
                }
                else
                {
                    return null;
                }
            }
            catch (Exception ex)
            {
                throw new Exception("ZD_PHIEUNHAPKHOCT::SelectByPrimaryKey::Error occured.", ex);
            }
            finally
            {             
                MainConnection.Close();
                sqlCommand.Dispose();
            }

        }


        /// <summary>
        /// Select all rescords
        /// </summary>
        /// <returns>list of ZD_PHIEUNHAPKHOCT</returns>
        public List<ZD_PHIEUNHAPKHOCT> SelectAll_List()
        {
            SqlCommand sqlCommand = new SqlCommand();
            sqlCommand.CommandText = "dbo.[zD_PHIEUNHAPKHOCT_SelectAll]";
            sqlCommand.CommandType = CommandType.StoredProcedure;

            // Use connection object of base class
            sqlCommand.Connection = MainConnection;

            try
            {
                
                MainConnection.Open();

                IDataReader dataReader = sqlCommand.ExecuteReader();

                return PopulateObjectsFromReader(dataReader);

            }
            catch (Exception ex)
            {                
                throw new Exception("ZD_PHIEUNHAPKHOCT::SelectAll::Error occured.", ex);
            }
            finally
            {
                MainConnection.Close();
                sqlCommand.Dispose();
            }

        }

        /// <summary>
        /// Select records by field
        /// </summary>
        /// <param name="fieldName">name of field</param>
        /// <param name="value">value of field</param>
        /// <returns>list of ZD_PHIEUNHAPKHOCT</returns>
        public List<ZD_PHIEUNHAPKHOCT> SelectByField_List(string fieldName, object value)
        {

            SqlCommand sqlCommand = new SqlCommand();
            sqlCommand.CommandText = "dbo.[zD_PHIEUNHAPKHOCT_SelectByField]";
            sqlCommand.CommandType = CommandType.StoredProcedure;

            // Use connection object of base class
            sqlCommand.Connection = MainConnection;

            try
            {

                sqlCommand.Parameters.Add(new SqlParameter("@FieldName", fieldName));
                sqlCommand.Parameters.Add(new SqlParameter("@Value", value));

                MainConnection.Open();
                
                IDataReader dataReader = sqlCommand.ExecuteReader();

                return PopulateObjectsFromReader(dataReader);

            }
            catch (Exception ex)
            {
                throw new Exception("ZD_PHIEUNHAPKHOCT::SelectByField::Error occured.", ex);
            }
            finally
            {

                MainConnection.Close();
                sqlCommand.Dispose();
            }

        }

//thêm hiennv

        /// <summary>
        /// Select all rescords
        /// </summary>
        /// <returns>dataTable</returns>
        public DataTable SelectAll()
        {
            SqlCommand sqlCommand = new SqlCommand();
            sqlCommand.CommandText = "dbo.[zD_PHIEUNHAPKHOCT_SelectAll]";
            sqlCommand.CommandType = CommandType.StoredProcedure;

            // Use connection object of base class
            sqlCommand.Connection = MainConnection;

            try
            {
                
                MainConnection.Open();

                DataTable ds = new DataTable();
                SqlDataAdapter myadapter = new SqlDataAdapter(sqlCommand);
                myadapter.Fill(ds);

                return ds;

            }
            catch (Exception ex)
            {                
                throw new Exception("ZD_PHIEUNHAPKHOCT::SelectAll::Error occured.", ex);
            }
            finally
            {
                MainConnection.Close();
                sqlCommand.Dispose();
            }

        }

        /// <summary>
        /// Select records by field
        /// </summary>
        /// <param name="fieldName">name of field</param>
        /// <param name="value">value of field</param>
        /// <returns>dataTable</returns>
        public DataTable SelectByField(string fieldName, object value)
        {

            SqlCommand sqlCommand = new SqlCommand();
            sqlCommand.CommandText = "dbo.[zD_PHIEUNHAPKHOCT_SelectByField]";
            sqlCommand.CommandType = CommandType.StoredProcedure;

            // Use connection object of base class
            sqlCommand.Connection = MainConnection;

            try
            {

                sqlCommand.Parameters.Add(new SqlParameter("@FieldName", fieldName));
                sqlCommand.Parameters.Add(new SqlParameter("@Value", value));

                MainConnection.Open();
                
                DataTable ds = new DataTable();
                SqlDataAdapter myadapter = new SqlDataAdapter(sqlCommand);
                myadapter.Fill(ds);

                return ds;

            }
            catch (Exception ex)
            {
                throw new Exception("ZD_PHIEUNHAPKHOCT::SelectByField::Error occured.", ex);
            }
            finally
            {

                MainConnection.Close();
                sqlCommand.Dispose();
            }

        }     
//end thêm hiennv
        #endregion

        #region Private Methods

        /// <summary>
        /// Populate business object from data reader
        /// </summary>
        /// <param name="businessObject">business object</param>
        /// <param name="dataReader">data reader</param>
        internal void PopulateBusinessObjectFromReader(ZD_PHIEUNHAPKHOCT businessObject, IDataReader dataReader)
        {


				businessObject.Id = dataReader.GetInt64(dataReader.GetOrdinal(ZD_PHIEUNHAPKHOCT.ZD_PHIEUNHAPKHOCTFields.Id.ToString()));

				if (!dataReader.IsDBNull(dataReader.GetOrdinal(ZD_PHIEUNHAPKHOCT.ZD_PHIEUNHAPKHOCTFields.Sophieu.ToString())))
				{
					businessObject.Sophieu = dataReader.GetString(dataReader.GetOrdinal(ZD_PHIEUNHAPKHOCT.ZD_PHIEUNHAPKHOCTFields.Sophieu.ToString()));
				}

				if (!dataReader.IsDBNull(dataReader.GetOrdinal(ZD_PHIEUNHAPKHOCT.ZD_PHIEUNHAPKHOCTFields.Mavt.ToString())))
				{
					businessObject.Mavt = dataReader.GetString(dataReader.GetOrdinal(ZD_PHIEUNHAPKHOCT.ZD_PHIEUNHAPKHOCTFields.Mavt.ToString()));
				}

				if (!dataReader.IsDBNull(dataReader.GetOrdinal(ZD_PHIEUNHAPKHOCT.ZD_PHIEUNHAPKHOCTFields.Mavach.ToString())))
				{
					businessObject.Mavach = dataReader.GetInt64(dataReader.GetOrdinal(ZD_PHIEUNHAPKHOCT.ZD_PHIEUNHAPKHOCTFields.Mavach.ToString()));
				}

				if (!dataReader.IsDBNull(dataReader.GetOrdinal(ZD_PHIEUNHAPKHOCT.ZD_PHIEUNHAPKHOCTFields.Solo.ToString())))
				{
					businessObject.Solo = dataReader.GetString(dataReader.GetOrdinal(ZD_PHIEUNHAPKHOCT.ZD_PHIEUNHAPKHOCTFields.Solo.ToString()));
				}

				if (!dataReader.IsDBNull(dataReader.GetOrdinal(ZD_PHIEUNHAPKHOCT.ZD_PHIEUNHAPKHOCTFields.Soluong.ToString())))
				{
					businessObject.Soluong = dataReader.GetDouble(dataReader.GetOrdinal(ZD_PHIEUNHAPKHOCT.ZD_PHIEUNHAPKHOCTFields.Soluong.ToString()));
				}

				if (!dataReader.IsDBNull(dataReader.GetOrdinal(ZD_PHIEUNHAPKHOCT.ZD_PHIEUNHAPKHOCTFields.Dongianhap.ToString())))
				{
					businessObject.Dongianhap = dataReader.GetDouble(dataReader.GetOrdinal(ZD_PHIEUNHAPKHOCT.ZD_PHIEUNHAPKHOCTFields.Dongianhap.ToString()));
				}

				if (!dataReader.IsDBNull(dataReader.GetOrdinal(ZD_PHIEUNHAPKHOCT.ZD_PHIEUNHAPKHOCTFields.Thanhtien.ToString())))
				{
					businessObject.Thanhtien = dataReader.GetDouble(dataReader.GetOrdinal(ZD_PHIEUNHAPKHOCT.ZD_PHIEUNHAPKHOCTFields.Thanhtien.ToString()));
				}

				if (!dataReader.IsDBNull(dataReader.GetOrdinal(ZD_PHIEUNHAPKHOCT.ZD_PHIEUNHAPKHOCTFields.Ngaysx.ToString())))
				{
					businessObject.Ngaysx = dataReader.GetDateTime(dataReader.GetOrdinal(ZD_PHIEUNHAPKHOCT.ZD_PHIEUNHAPKHOCTFields.Ngaysx.ToString()));
				}

				if (!dataReader.IsDBNull(dataReader.GetOrdinal(ZD_PHIEUNHAPKHOCT.ZD_PHIEUNHAPKHOCTFields.Hansd.ToString())))
				{
					businessObject.Hansd = dataReader.GetDateTime(dataReader.GetOrdinal(ZD_PHIEUNHAPKHOCT.ZD_PHIEUNHAPKHOCTFields.Hansd.ToString()));
				}

				if (!dataReader.IsDBNull(dataReader.GetOrdinal(ZD_PHIEUNHAPKHOCT.ZD_PHIEUNHAPKHOCTFields.Sodutru.ToString())))
				{
					businessObject.Sodutru = dataReader.GetInt64(dataReader.GetOrdinal(ZD_PHIEUNHAPKHOCT.ZD_PHIEUNHAPKHOCTFields.Sodutru.ToString()));
				}

				if (!dataReader.IsDBNull(dataReader.GetOrdinal(ZD_PHIEUNHAPKHOCT.ZD_PHIEUNHAPKHOCTFields.Nhacc.ToString())))
				{
					businessObject.Nhacc = dataReader.GetString(dataReader.GetOrdinal(ZD_PHIEUNHAPKHOCT.ZD_PHIEUNHAPKHOCTFields.Nhacc.ToString()));
				}

				if (!dataReader.IsDBNull(dataReader.GetOrdinal(ZD_PHIEUNHAPKHOCT.ZD_PHIEUNHAPKHOCTFields.Hopdong.ToString())))
				{
					businessObject.Hopdong = dataReader.GetInt64(dataReader.GetOrdinal(ZD_PHIEUNHAPKHOCT.ZD_PHIEUNHAPKHOCTFields.Hopdong.ToString()));
				}

				if (!dataReader.IsDBNull(dataReader.GetOrdinal(ZD_PHIEUNHAPKHOCT.ZD_PHIEUNHAPKHOCTFields.Baogia.ToString())))
				{
					businessObject.Baogia = dataReader.GetString(dataReader.GetOrdinal(ZD_PHIEUNHAPKHOCT.ZD_PHIEUNHAPKHOCTFields.Baogia.ToString()));
				}

				if (!dataReader.IsDBNull(dataReader.GetOrdinal(ZD_PHIEUNHAPKHOCT.ZD_PHIEUNHAPKHOCTFields.Stt.ToString())))
				{
					businessObject.Stt = (byte?)dataReader.GetInt16(dataReader.GetOrdinal(ZD_PHIEUNHAPKHOCT.ZD_PHIEUNHAPKHOCTFields.Stt.ToString()));
				}

				if (!dataReader.IsDBNull(dataReader.GetOrdinal(ZD_PHIEUNHAPKHOCT.ZD_PHIEUNHAPKHOCTFields.Ghichu.ToString())))
				{
					businessObject.Ghichu = dataReader.GetString(dataReader.GetOrdinal(ZD_PHIEUNHAPKHOCT.ZD_PHIEUNHAPKHOCTFields.Ghichu.ToString()));
				}

				if (!dataReader.IsDBNull(dataReader.GetOrdinal(ZD_PHIEUNHAPKHOCT.ZD_PHIEUNHAPKHOCTFields.Vat.ToString())))
				{
					businessObject.Vat = dataReader.GetDouble(dataReader.GetOrdinal(ZD_PHIEUNHAPKHOCT.ZD_PHIEUNHAPKHOCTFields.Vat.ToString()));
				}

				if (!dataReader.IsDBNull(dataReader.GetOrdinal(ZD_PHIEUNHAPKHOCT.ZD_PHIEUNHAPKHOCTFields.Giaban.ToString())))
				{
					businessObject.Giaban = dataReader.GetDouble(dataReader.GetOrdinal(ZD_PHIEUNHAPKHOCT.ZD_PHIEUNHAPKHOCTFields.Giaban.ToString()));
				}


        }

        /// <summary>
        /// Populate business objects from the data reader
        /// </summary>
        /// <param name="dataReader">data reader</param>
        /// <returns>list of ZD_PHIEUNHAPKHOCT</returns>
        internal List<ZD_PHIEUNHAPKHOCT> PopulateObjectsFromReader(IDataReader dataReader)
        {

            List<ZD_PHIEUNHAPKHOCT> list = new List<ZD_PHIEUNHAPKHOCT>();

            while (dataReader.Read())
            {
                ZD_PHIEUNHAPKHOCT businessObject = new ZD_PHIEUNHAPKHOCT();
                PopulateBusinessObjectFromReader(businessObject, dataReader);
                list.Add(businessObject);
            }
            return list;

        }

        #endregion

	}
}
